package com.jiaxianm.secure.controller;

import com.jiaxianm.secure.annotation.ResponseEncrypt;
import com.jiaxianm.secure.entity.R;
import com.jiaxianm.secure.entity.TbStudentEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName : TbStudentController
 * @Description : 前端控制器Controller测试类
 */

@RestController
@RequestMapping("/demo")
@Slf4j
public class TbStudentController {

    @PostMapping("/encryptPost")
    @ResponseEncrypt
    public R postDemo(@RequestBody TbStudentEntity tbStudentEntity, HttpServletRequest request){
        System.out.println("request.getParameter(\"aesKey\") = " + request.getParameter("aesKey"));
        //System.out.println("request.getAttribute(\"aesKey\") = " + request.getAttribute("aesKey"));
        System.out.println("tbStudentEntity = " + tbStudentEntity);
        return R.ok(tbStudentEntity.toString());
    }

    @GetMapping("/encryptGet")
    @ResponseEncrypt
    public R postDemoGet(HttpServletRequest request,@RequestParam String id,@RequestParam String name,@RequestParam String aesKey ){
        System.out.println("id = " + id);
        System.out.println("name = " + name);
        System.out.println("aesKey = " + aesKey);
        System.out.println("request.getParameter(\"age\") = " + request.getParameter("age"));
        //System.out.println("request.getAttribute(DecryptReplaceStreamFilter.AKS_PARAMETER) = " + request.getAttribute(DecryptReplaceStreamFilter.AKS_PARAMETER));
        return R.ok();
    }
}
